package com.itzh.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class JdkHaipi implements InvocationHandler {

    private Haipi target;

    public Object getInstance(Haipi target){
        this.target = target;
        Class<? extends Haipi> clazz = target.getClass();

        Object o = Proxy.newProxyInstance(clazz.getClassLoader(), clazz.getInterfaces(), this);

        return o;
    }


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("开始了");
        method.invoke(this.target,args);
        System.out.println("准备了");
        return null;
    }
}
